/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.annuaireComp.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author MiniK
 */
@Entity
@Table(name = "domaine_competence")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DomaineCompetence.findAll", query = "SELECT d FROM DomaineCompetence d"),
    @NamedQuery(name = "DomaineCompetence.findByIddomaineCompetence", query = "SELECT d FROM DomaineCompetence d WHERE d.iddomaineCompetence = :iddomaineCompetence"),
    @NamedQuery(name = "DomaineCompetence.findByLibelle", query = "SELECT d FROM DomaineCompetence d WHERE d.libelle = :libelle")})
public class DomaineCompetence implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "iddomaine_competence")
    private Integer iddomaineCompetence;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "libelle")
    private String libelle;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "domaineCompetence", fetch = FetchType.EAGER)
    private List<Competence> competenceList;

    public DomaineCompetence() {
    }

    public DomaineCompetence(Integer iddomaineCompetence) {
        this.iddomaineCompetence = iddomaineCompetence;
    }

    public DomaineCompetence(Integer iddomaineCompetence, String libelle) {
        this.iddomaineCompetence = iddomaineCompetence;
        this.libelle = libelle;
    }

    public Integer getIddomaineCompetence() {
        return iddomaineCompetence;
    }

    public void setIddomaineCompetence(Integer iddomaineCompetence) {
        this.iddomaineCompetence = iddomaineCompetence;
    }

    public String getLibelle() {
        return libelle;
    }

    public void setLibelle(String libelle) {
        this.libelle = libelle;
    }

    @XmlTransient
    public List<Competence> getCompetenceList() {
        return competenceList;
    }

    public void setCompetenceList(List<Competence> competenceList) {
        this.competenceList = competenceList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iddomaineCompetence != null ? iddomaineCompetence.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DomaineCompetence)) {
            return false;
        }
        DomaineCompetence other = (DomaineCompetence) object;
        if ((this.iddomaineCompetence == null && other.iddomaineCompetence != null) || (this.iddomaineCompetence != null && !this.iddomaineCompetence.equals(other.iddomaineCompetence))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fr.annuaireComp.entities.DomaineCompetence[ iddomaineCompetence=" + iddomaineCompetence + " ]";
    }
    
}
